import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CascaderOption } from '@iux/live/cascader/interface';

@Component({
  selector: 'app-default-value',
  templateUrl: './default-value.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DefaultValueComponent {
  options: CascaderOption[] = [
    {
      value: 'zhejiang',
      label: 'Zhejiang',
      children: [
        {
          value: 'hangzhou',
          label: 'Hangzhou',
          children: [
            {
              value: 'xihu',
              label: 'West Lake',
              isLeaf: true,
            },
          ],
        },
        {
          value: 'ningbo',
          label: 'Ningbo',
          isLeaf: true,
        },
      ],
    },
    {
      value: 'jiangsu',
      label: 'Jiangsu',
      children: [
        {
          value: 'nanjing',
          label: 'Nanjing',
          children: [
            {
              value: 'zhonghuamen',
              label: 'Zhong Hua Men',
              isLeaf: true,
            },
          ],
        },
      ],
    },
  ];

  values: string[] | null = ['zhejiang', 'hangzhou', 'xihu'];

  onChanges(values: string[]): void {
    console.log(values, this.values);
  }

  onSelectionChange(selection: CascaderOption[]): void {
    console.log('selection', selection);
  }

  onClear(): void {
    console.log('clear');
  }
}
